/*
 * Copyright Radosław Smogura, 2012. All rights reserved.
 *
 * The content of this file is confidential and it is intelectual property
 * of copyright owners.
 * 
 *
 * $URL: http://reprap-ide.googlecode.com/svn/trunk/RepRapIDE/RepRapProject/src/main/java/eu/softper/reprap/generator/NumericFactoryDouble.java $
 * $Id: NumericFactoryDouble.java 3 2012-11-19 10:58:30Z mail@smogura.eu $
 * $Revision: 3 $
 */
package eu.softper.reprap.generator;

import java.math.BigDecimal;

/**
 *
 * @author rsmogura
 */
public class NumericFactoryDouble extends NumericFactory<Double> {

    @Override
    public Double valueOf(double val) {
        return Double.valueOf(val);
    }

    @Override
    public Double valueOf(BigDecimal val) {
        return Double.valueOf(val.doubleValue());
    }

    @Override
    public boolean isPositive(Double t) {
        return t > 0.0d;
    }

    @Override
    public boolean isNegative(Double t) {
        return t < 0.0d;
    }

    @Override
    public boolean isNotZero(Double t) {
        return t != 0.0d;
    }

    @Override
    public Double add(Double a, Double b) {
       return a + b;
    }

    @Override
    public Double degreeAsRemainder(Double degree) {
        double rest = degree % 360.0;
        if (rest < 0)
            return rest + 360;
        else
            return rest;
    }

    @Override
    public Double subs(Double a, Double b) {
        return a - b;
    }

    @Override
    public Double mul(Double a, Double b) {
        return a * b;
    }

    @Override
    public Double reminder(Double a, Double b) {
        return a % b;
    }

    @Override
    public Double abs(Double t) {
        return Math.abs(t);
    }

    @Override
    public Double min(Double a, Double b) {
        return Math.min(a, b);
    }

    @Override
    public Double max(Double a, Double b) {
        return Math.max(a, b);
    }

    @Override
    public Double negate(Double t) {
        return -t;
    }

    @Override
    public Double div(Double a, Double b) {
        return a / b;
    }

    @Override
    public Double round(Double a, Double r) {
        long integer = (long) (a / r);
        return r * integer;
    }
}
